home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libpam0g.postinst < prev    next >
Text File  |  2009-09-04  |  6KB  |  220 lines

  1. #!/bin/sh
  2.  
  3. # postinst based heavily on the postinst of libssl0.9.8, courtesy of 
  4. # Christoph Martin.
  5.  
  6. . /usr/share/debconf/confmodule
  7.  
  8. set -e
  9.  
  10. # element() is a helper function for file-rc:
  11. element() {
  12.     local element list IFS
  13.  
  14.     element="$1"
  15.  
  16.     [ "$2" = "in" ] && shift
  17.     list="$2"
  18.     [ "$list" = "-" ] && return 1
  19.     [ "$list" = "*" ] && return 0
  20.  
  21.     IFS=","
  22.     set -- $list
  23.     case $element in
  24.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  25.         return 0
  26.     esac
  27.     return 1
  28. }
  29.  
  30. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  31. # running in $runlevel:
  32. filerc() {
  33.     local runlevel basename
  34.     runlevel=$1
  35.     basename=$2
  36.     while read LINE
  37.     do
  38.     case $LINE in
  39.         \#*|"") continue
  40.     esac
  41.  
  42.     set -- $LINE
  43.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  44.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  45.  
  46.     if element "$runlevel" in "$START" || element "S" in "$START"
  47.     then
  48.         echo "/etc/init.d/$basename"
  49.         return 0
  50.     fi
  51.     done < /etc/runlevel.conf
  52.     echo ""
  53. }
  54.  
  55. installed_services() {
  56.     check="$@"
  57.  
  58.     # Only get the ones that are installed, and configured
  59.     check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  60.  
  61.     # some init scripts don't match the package names
  62.     check=$(echo $check | \
  63.     sed -e's/\bapache2-common\b/apache2/g' \
  64.         -e's/\bat\b/atd/g' \
  65.         -e's/\bdovecot-common\b/dovecot/g' \
  66.         -e's/\bdante-server\b/danted/g' \
  67.         -e's/\bexim4-base\b/exim4/g' \
  68.         -e's/\bheartbeat-2\b/heartbeat/g' \
  69.         -e's/\bhylafax-server\b/hylafax/g' \
  70.         -e's/\bpartimage-server\b/partimaged/g' \
  71.         -e's/\bsasl2-bin\b/saslauthd/g' \
  72.     )
  73.  
  74.     for service in $check; do
  75.     idl="/etc/init.d/${service}"
  76.     if [ -n "$idl" ] && [ -x $idl ]; then
  77.         services="$service $services"
  78.     else
  79.         echo "WARNING: init script for $service not found." >&2
  80.     fi
  81.     done
  82.     echo "$services"
  83. }
  84.  
  85. if [ "$1" = "configure" ]
  86. then
  87.     if [ ! -z "$2" ]; then
  88.     if dpkg --compare-versions "$2" lt 1.1.0; then
  89.         db_version 2.0
  90.  
  91.         echo -n "Checking for services that may need to be restarted..."
  92.  
  93.         check="apache2-common at bayonne cherokee courier-authdaemon"
  94.         check="$check cron cups"
  95.         check="$check dante-server diald dovecot-common exim exim4-base"
  96.         check="$check fcron fireflier-server freeradius gdm heartbeat"
  97.         check="$check heartbeat-2 hylafax-server iiimf-server inn2"
  98.         check="$check kannel linesrv linesrv-mysql lsh-server"
  99.         check="$check muddleftpd netatalk nuauth partimage-server"
  100.         check="$check perdition pgpool popa3d postgresql-7.4"
  101.         check="$check postgresql-8.1 postgresql-8.2 proftpd pure-ftpd"
  102.         check="$check pure-ftpd-ldap pure-ftpd-mysql"
  103.         check="$check pure-ftpd-postgresql racoon samba sasl2-bin"
  104.         check="$check sfs-server solid-pop3d squid squid3 tac-plus"
  105.         check="$check vsftpd wu-ftpd wzdftpd xrdp yardradius yaws"
  106.  
  107.         if ! who | awk '{print $2}'|grep -q ':[0-9]'; then
  108.         check="$check kdm wdm xdm"
  109.         fi
  110.  
  111.         echo "Checking init scripts..."
  112.         services=$(installed_services "$check")
  113.         if [ -n "$services" ]; then
  114.         db_reset libpam0g/restart-services
  115.         db_set libpam0g/restart-services "$services"
  116.         question_priority="critical"
  117.         # Do not prompt when we're running in the upgrade-manager
  118.         # and only default services need restarting.
  119.         nondefault_services=$(echo "$services" | sed \
  120.             -e's/\batd\b//g' \
  121.             -e's/\bcron\b//g' \
  122.             -e's/\bcups\b//g' \
  123.             -e's/\bgdm\b//g' \
  124.             -e's/\bkdm\b//g' \
  125.             -e's/\bsamba\b//g' \
  126.             -e's/^ *//g')
  127.         if [ -n "$RELEASE_UPGRADE_IN_PROGRESS" ] && [ -z "$nondefault_services" ]; then
  128.             question_priority="medium"
  129.         fi
  130.         db_input "$question_priority" libpam0g/restart-services || true
  131.         db_go || true
  132.         db_get libpam0g/restart-services
  133.  
  134.         if [ "x$RET" != "x" ]
  135.         then
  136.             services=$RET
  137.         else
  138.             services=""
  139.         fi
  140.         echo
  141.         if [ "$services" != "" ]; then
  142.             echo "Restarting services possibly affected by the upgrade:"
  143.             failed=""
  144.             rl=$(runlevel | sed 's/.*\ //')
  145.             for service in $services; do
  146.             idl="invoke-rc.d ${service}"
  147.  
  148.             case "$service" in
  149.                 gdm)
  150.                 echo -n "  $service: reloading..."
  151.                 if $idl reload > /dev/null 2>&1; then
  152.                     echo "done."
  153.                 else
  154.                     echo "FAILED! ($?)"
  155.                     failed="$service $failed"
  156.                 fi
  157.                 continue
  158.                 ;;
  159.             esac
  160.             echo -n "  $service: stopping..."
  161.             $idl stop > /dev/null 2>&1 || true
  162.             sleep 1
  163.             echo -n "starting..."
  164.             if $idl start > /dev/null 2>&1; then
  165.                 echo "done."
  166.             else
  167.                 echo "FAILED! ($?)"
  168.                 failed="$service $failed"
  169.             fi
  170.             done
  171.             echo
  172.             if [ -n "$failed" ]; then
  173.             db_subst libpam0g/restart-failed services "$failed"
  174.             db_input critical libpam0g/restart-failed || true
  175.             db_go || true
  176.             else
  177.             echo "Services restarted successfully."
  178.             fi
  179.             echo
  180.         fi
  181.         else
  182.         echo "Nothing to restart."
  183.         fi
  184.  
  185.         if who | awk '{print $2}' | grep -q ':[0-9]'; then
  186.         dms=""
  187.         for service in kdm wdm xdm; do
  188.             case "$services" in
  189.             *$service*)    ;;
  190.             *)    dms="$dms $service"
  191.             esac
  192.         done
  193.         services=$(installed_services "$dms")
  194.         if [ -n "$services" ]; then
  195.             if [ -n "$RELEASE_UPGRADE_IN_PROGRESS" ] \
  196.                && [ -x /usr/share/update-notifier/notify-reboot-required ]
  197.             then
  198.             /usr/share/update-notifier/notify-reboot-required
  199.             else
  200.             db_input critical libpam0g/xdm-needs-restart || true
  201.             db_go || true
  202.             fi
  203.         fi
  204.         fi
  205.  
  206.         # Shut down the frontend, to make sure none of the
  207.         # restarted services keep a connection open to it
  208.         db_stop
  209.     fi # end upgrading and $2 lt 1.1.0
  210.     fi # Upgrading
  211. fi
  212.  
  213. # Automatically added by dh_makeshlibs
  214. if [ "$1" = "configure" ]; then
  215.     ldconfig
  216. fi
  217. # End automatically added section
  218.  
  219.  
  220.